From: Marina Zhurakhinskaya Date: Mon, 17 Oct 2011 21:50:02 +0000 (-0400) Subject: notificationDaemon: only display a large image if an icon is also specified X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7425 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9593ff3582535aa264d44bcffffb59b8cddf169a;p=gnome-shell.git notificationDaemon: only display a large image if an icon is also specified Historically, when applications set "image-data" they expect it to show up as an icon. So we display it as such if an icon is not specified with an "app_icon" argument to Notify(). We also use "image-path" for an icon if an icon is not specified. We only display a large image specified with "image-data" or "image-path" if an icon is also specified. https://bugzilla.gnome.org/show_bug.cgi?id=659158 --- diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index 4ec556a85..f40205d6a 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -109,6 +109,14 @@ NotificationDaemon.prototype = { _iconForNotificationData: function(icon, hints, size) { let textureCache = St.TextureCache.get_default(); + // If an icon is not specified, we use 'image-data' or 'image-path' hint for an icon + // and don't show a large image. There are currently many applications that use + // notify_notification_set_icon_from_pixbuf() from libnotify, which in turn sets + // the 'image-data' hint. These applications don't typically pass in 'app_icon' + // argument to Notify() and actually expect the pixbuf to be shown as an icon. + // So the logic here does the right thing for this case. If both an icon and either + // one of 'image-data' or 'image-path' are specified, we show both an icon and + // a large image. if (icon) { if (icon.substr(0, 7) == 'file://') return textureCache.load_uri_async(icon, size, size); @@ -119,6 +127,12 @@ NotificationDaemon.prototype = { return new St.Icon({ icon_name: icon, icon_type: St.IconType.FULLCOLOR, icon_size: size }); + } else if (hints['image-data']) { + let [width, height, rowStride, hasAlpha, + bitsPerSample, nChannels, data] = hints['image-data']; + return textureCache.load_from_raw(data, hasAlpha, width, height, rowStride, size); + } else if (hints['image-path']) { + return textureCache.load_uri_async(GLib.filename_to_uri(hints['image-path'], null), size, size); } else { let stockIcon; switch (hints.urgency) { @@ -330,7 +344,8 @@ NotificationDaemon.prototype = { clear: true }); } - if (hints['image-data'] || hints['image-path']) { + // We only display a large image if an icon is also specified. + if (icon && (hints['image-data'] || hints['image-path'])) { let image = null; if (hints['image-data']) { let [width, height, rowStride, hasAlpha,